﻿@model trangbaocao.Models.Device_StationsModel
<div class="container_12">       
    <div class="grid_12">            
        <div class="module">
                <h2 align="right"><span align="right"><a href="@Url.Action("Index", "Device_Stations")">Quay lại</a></span></h2>                        
                <div class="module-body">
                @using (Html.BeginForm("EditDevice_Stations", "Device_Stations", FormMethod.Post, new { id = "EditDevice_Stations" }))
                {                      
                    <div align="center" style="margin-bottom:10px;">
                        <h3>SỬA THÔNG TIN THIẾT BỊ TRONG TRẠM</h3>
                        <div class="img-device-station-edit" align="center">
                            <img src="@Url.Content("~/Content/Body/Images/Body_Images/Edit_Device.png")" width="12%" /> 
                        </div>
                    </div>
                    if (TempData["msg"] != null)
                    {                            
                        <span class="notification n-error">@TempData["msg"]</span>
                    } 
         <table>
            <div style="width:50%; text-align:center; float:left; margin-bottom:5px">
                    <p align="center">
                        <label style="width:55%; text-align:left;">Mã thết bị:</label>
                        <div class="ma_he_thong" align="center" style="padding-left: 0px; width: 100%">
                            @Html.TextBoxFor(model => model.ma_he_thong, new { @name = "ma_he_thong", @class = "input-medium" })  
                            @Html.HiddenFor(model => model.ma_he_thong)
                        </div>                                            
                    </p>      
                    <p align="center">
                        <label style="width:55%; text-align:left;">Tên thiết bị:</label>
                        <div class="thietbi" align="center" style="padding-left:0px; width: 100%; margin-left:0px">
                            @Html.TextBoxFor(model => model.name, new { @name = "name", @class = "input-medium" }) 
                            @Html.HiddenFor(model => model.name)
                            @*<font color="red">(*)</font>*@
                            <label style="width:60%; text-align:left;">
                            @Html.ValidationMessageFor(model => model.name)
                            </label> 
                        </div>                                            
                    </p>
                    <p align="center">
                        <label style="width:55%; text-align:left;">Trung tâm:</label>
                        @if (Model.trungtam_id != null)
                        { 
                            @Html.DropDownListFor(x => x.main_stations_id, Model.trungtam_id, new { })  
                            @Html.HiddenFor(x => x.main_stations_id)                 
                        }
                    </p>
                    <p align="center" style="padding-left:0px; width:100%">
                        <label style="width:55%; text-align:left; padding-left:px">Trạm:</label>
                             @if (Model.tram_id != null)
                             {   
                                                              
                                    @Html.DropDownListFor(x => x.stations_id, Model.tram_id, new { @style = "width:55%; margin-left:0px" })
                                    @Html.HiddenFor(x => x.stations_id) 
                             }    
                             @*<font color="red">(*)</font>*@                         
                        <label style="width:55%; text-align:left;">
                            @Html.ValidationMessageFor(model => model.stations_id)
                        </label>                    
                    </p>
                    <p align="center">
                        <label style="width:55%; text-align:left;">Thiết bị:</label>
                        @if (Model.thietbi_id != null)
                        {
                            @Html.DropDownListFor(x => x.device_id, Model.thietbi_id, new { @disabled = "disabled" })
                            //@Html.DropDownListFor("deviceid", Model.thietbi_id, new {@disabled = "disabled"})
                        }                        
                    </p>
                    @Html.HiddenFor(x => x.device_id)
                    
                    </div>
                    <div style="width:50%; text-align:center; float:left; margin-bottom:5px">

                    <div align="center">
                        <label style="width:55%; text-align:left;">Ngày lắp đặt:</label>
                            <p align="center" style="width:55%; text-align:left;">
                                @Html.TextBoxFor(model => model.ngay_lap_dat, new { @name = "ngay_lap_dat", @class = "date" })
                                <font color="red">(*)</font>
                                <label style="width:60%; text-align:left;">
                                @Html.ValidationMessageFor(model => model.ngay_lap_dat)
                                </label>
                            </p>  
                    </div>          
                     <div align="center">
                        <label style="width:55%; text-align:left;">Ngày sử dụng:</label>
                            <p align="center" style="width:55%; text-align:left;">
                                @Html.TextBoxFor(model => model.ngay_su_dung, new { @name = "ngay_su_dung", @class = "date" })
                                <font color="red">(*)</font>
                                <label style="width:60%; text-align:left;">
                                @Html.ValidationMessageFor(model => model.ngay_su_dung)
                                </label>
                            </p> 
                    </div>
                    @*<p align="center">
                        <label style="width:55%; text-align:left;">Số hiệu thuê bao:</label>
                        @Html.TextBoxFor(model => model.so_hieu_tb, new { @name = "so_hieu_tb", @class = "input-medium" })
                        
                    </p>*@
                    @*<div align="center">
                        <label style="width:26%; text-align:left;">Ngày lắp đặt:</label>
                            <p align="center" style="width:27%; text-align:left;">
                                @Html.TextBoxFor(model => model.ngay_lap_dat, new { @name = "ngay_lap_dat", @class = "date" })
                            </p>                        
                    </div>*@
                    @*<p align="center">
                        <label style="width:55%; text-align:left;">Thông tin thuê bao:</label>
                        @Html.TextBoxFor(model => model.thong_tin_tb, new { @name = "thong_tin_tb", @class = "input-medium" })
                        
                    </p>*@
                    <p align="center">
                       <label style="width:55%; text-align:left;">Trạng thái hoạt động:</label>
                        <select name="trang_thai_hd">
                            <option value="1"  @(Model.trang_thai_hd == 1 ? "selected" : "")>Bình thường</option>
                            <option value="0" @(Model.trang_thai_hd == 0 ? "selected" : "")>Ngừng</option>
                        </select>                        
                    </p>
                    <p align="center">
                        <label style="width:55%; text-align:left;">Nhân viên lắp đặt:</label>
                        @Html.TextBoxFor(model => model.nv_lap_dat, new { @name = "nv_lap_dat", @class = "input-medium" })
                        
                    </p>
                    @*<div align="center">
                        <label style="width:26%; text-align:left;">Ngày sử dụng:</label>
                            <p align="center" style="width:27%; text-align:left;">
                                @Html.TextBoxFor(model => model.ngay_su_dung, new { @name = "ngay_su_dung", @class = "date" }) 
                            </p>                       
                    </div>*@
                    <p align="center">
                        <label style="width:55%; text-align:left;">Ghi chú:</label>
                        @Html.TextBoxFor(model => model.ghi_chu, new { @name = "ghi_chu", @class = "input-medium" })
                        
                    </p>
                    </div>
      </table>                    
                    <div class="button" align="center">
                        <p align="center" style="width:26%; text-align:center;">
                            <input class="submit-green" type="submit" value="Sửa" /> 
                            <input class="submit-gray" type="reset" value="Hủy" />
                            @*<input class="submit-gray" type="button"  onclick="location.href='@Url.Action("Index", "User")'" value="Quay lại" />*@
                        </p>
                    </div>  
                }
                </div> <!-- End .module-body -->
        </div>  <!-- End .module -->
        <div style="clear:both;"></div>
    </div> <!-- End .grid_12 --> 
    <div style="clear:both;"></div>
</div> <!-- End .container_12 -->

<script type="text/javascript">
    $(document).ready(function () {
        $("#date").datepicker({ dateFormat: 'dd/mm/yy' });
    });
</script>
<script type="text/javascript">
    $("#main_stations_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getStationsJson", "Device_Stations")',
            data: { MainStationId: $("#main_stations_id > option:selected").attr("value"),Order:"name" },
            success: function (data) {
                var items = [];
                items.push("<option>---Chọn nhà trạm---</option>");
                $.each(data, function () {
                    items.push("<option value=" + this.Value + ">" + this.Text + "</option>");
                });
                $("#stations_id").html(items.join(' '));
            }
        })
    });
</script>
